package com.ksp.wke.kspb02;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ksp.dom.KSPDOM_ResDta;

import net.minidev.json.JSONArray;

@Controller
public class KSPB02Controller {

	@Autowired
	private KSPB02Mapper kspb02Mapper;

	@RequestMapping("/boa/KSPB021")
	@ResponseBody
	public KSPDOM_ResDta iniPam1(ServletRequest request) {
		Map<String, Object> wPamMap = new HashMap<>();
		KSPDOM_ResDta wResDta = new KSPDOM_ResDta();
		try {
			wResDta = exeSrv1(wPamMap);
		} catch (Exception e) {
			wResDta.setCod("400");
			wResDta.setMsg(e.getMessage());
		}
		return wResDta;
	}

	public KSPDOM_ResDta exeSrv1(Map<String, Object> pPamMap) {
		List<Map<String, Object>> wQryQuaLst = kspb02Mapper.qryQuaLst(pPamMap);
		
		return KSPDOM_ResDta.buildSucc(JSONArray.toJSONString(wQryQuaLst));
	}
	
	@RequestMapping("/boa/KSPB022")
	@ResponseBody
	public KSPDOM_ResDta iniPam2(ServletRequest request) {
		Map<String, Object> wPamMap = new HashMap<>();
		KSPDOM_ResDta wResDta = new KSPDOM_ResDta();
		try {
			wResDta = exeSrv2(wPamMap);
		} catch (Exception e) {
			wResDta.setCod("400");
			wResDta.setMsg(e.getMessage());
		}
		return wResDta;
	}

	public KSPDOM_ResDta exeSrv2(Map<String, Object> pPamMap) {
		List<Map<String, Object>> wQryQuaLst = kspb02Mapper.qryQuaLst(pPamMap);
		
		return KSPDOM_ResDta.buildSucc(JSONArray.toJSONString(wQryQuaLst));
	}
	
	@RequestMapping("/boa/KSPB023")
	@ResponseBody
	public KSPDOM_ResDta iniPam3(ServletRequest request) {
		Map<String, Object> wPamMap = new HashMap<>();
		KSPDOM_ResDta wResDta = new KSPDOM_ResDta();
		try {
			wResDta = exeSrv3(wPamMap);
		} catch (Exception e) {
			wResDta.setCod("400");
			wResDta.setMsg(e.getMessage());
		}
		return wResDta;
	}

	public KSPDOM_ResDta exeSrv3(Map<String, Object> pPamMap) {
		List<Map<String, Object>> wQryQuaLst = kspb02Mapper.qryQuaLst(pPamMap);
		
		return KSPDOM_ResDta.buildSucc(JSONArray.toJSONString(wQryQuaLst));
	}
	
	@RequestMapping("/boa/KSPB024")
	@ResponseBody
	public KSPDOM_ResDta iniPam4(ServletRequest request) {
		Map<String, Object> wPamMap = new HashMap<>();
		KSPDOM_ResDta wResDta = new KSPDOM_ResDta();
		try {
			wResDta = exeSrv4(wPamMap);
		} catch (Exception e) {
			wResDta.setCod("400");
			wResDta.setMsg(e.getMessage());
		}
		return wResDta;
	}

	public KSPDOM_ResDta exeSrv4(Map<String, Object> pPamMap) {
		List<Map<String, Object>> wQryQuaLst = kspb02Mapper.qryQuaLst(pPamMap);
		
		return KSPDOM_ResDta.buildSucc(JSONArray.toJSONString(wQryQuaLst));
	}
}
